package com.ushine.web;

import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author yls
 */
@SpringBootApplication(exclude = {
        DataSourceAutoConfiguration.class,
})
@ServletComponentScan
@EnableScheduling
public class FightTemplateWebApplication {

    @Resource
    private RestTemplateBuilder builder;

    @Bean
    public RestTemplate restTemplate() {
        return builder.build();
    }


    public static void main(String[] args) {
        SpringApplication.run(FightTemplateWebApplication.class, args);
    }

    /**
     * 功能描述:
     * 〈 防止 jasypt.encryptor.password 泄露
     * 在启动类里面或者配置文件中添加 〉
     *
     * @return : org.jasypt.encryption.StringEncryptor
     * @author : yls
     * @date : 2022/2/10 17:15
     */
    @Bean("jasyptStringEncryptor")
    public StringEncryptor stringEncryptor() {
        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
        config.setPassword("yls-fight");
        config.setPoolSize("1");
        encryptor.setConfig(config);
        return encryptor;
    }

}
